package com.xxx.resolver;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/8/23 13:34
 * @Copyright 博为峰
 */
@ControllerAdvice
public class GlobalExceptionResolver {

    @ExceptionHandler(NullPointerException.class)
    public void handleNullPointerException(Exception e) {
        System.out.println("NullPointerException");
        System.out.println(e.getMessage());
    }

    @ExceptionHandler(IndexOutOfBoundsException.class)
    public void handleIndexOutOfBoundsException(Exception e) {
        System.out.println("IndexOutOfBoundsException");
        System.out.println(e.getMessage());
    }

    @ExceptionHandler(RuntimeException.class)
    public void handleRuntimeException(Exception e) {
        System.out.println("RuntimeException");
        System.out.println(e.getMessage());
    }
}
